﻿#Persistent
#SingleInstance Force   ; 禁止多开

Menu, Tray, NoStandard  ; 先移除默认的菜单项（可选）
; Menu, Tray, Add, ❌退出, ExitScript  ; 添加退出选项
Menu, Tray, Add, 👀关于, ShowWindow  ; 添加一个自定义菜单项

Menu, Tray, NoIcon

StartLoop()  ; 明确调用循环

return


ShowWindow:
    Gui, New  ; 创建一个新窗口
    Gui, Add, Text, , ✉️反馈
    Gui, Add, Edit, ReadOnly, 3277250996@qq.com
    Gui, Add, Text, , 🔗官网
    Gui, Add, Edit, ReadOnly, https://gitee.com/chen-rongbin/DomainBlock
    Gui, Show,, domainblock-process
return


ExitScript:
    ; ExitApp

    ; 获取桌面路径
    desktop := A_Desktop
    killFile := desktop . "\退出-domainblock.cmd"
    FileDelete, %killFile%

    cmdStr1 := "for /f ""tokens=2"" %%i in ('tasklist ^| findstr domainblock-process') do taskkill /PID %%i /T /F"
    cmdStr2 := "mshta ""javascript:alert('已尝试关闭domainblock :-)');close()"""
    cmdStr := cmdStr1 . "`n" . cmdStr2 . "`n"
    FileAppend, %cmdStr%, %killFile%

    MsgBox, 请通过运行桌面上的 “退出-domainblock.cmd” 来退出本程序
Return


my_run(){
    RunWait, powershell.exe -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File ".\domainblock-registry.ps1", , Hide
}


StartLoop() {
    Loop
    {
        my_run()
        Sleep, 60000
    }
}









